import type {
  OrderPre,
  AddressItem,
  OrderDetail,
  Logistics,
} from '@/types/order'
import { request } from '@/utils/request'

// 获取药品订单物流信息
export const getMedicalOrderLogistics = (id: string) =>
  request<Logistics>({ url: `/patient/order/${id}/logistics` })

// 查询药品订单预支付信息
export const getMedicalOrderPre = (params: { prescriptionId: string }) =>
  request<OrderPre>({ url: '/patient/medicine/order/pre', data: params })

// 获取收货地址列表
export const getAddressList = () =>
  request<AddressItem[]>({ url: '/patient/order/address' })

// 创建药品订单
export const createMedicalOrder = (data: {
  id: string
  addressId: string
  couponId?: string
}) =>
  request<{ id: string }>({
    url: '/patient/medicine/order',
    data,
    method: 'POST',
  })

// 获取药品订单详情
export const getMedicalOrderDetail = (id: string) =>
  request<OrderDetail>({
    url: `/patient/medicine/order/detail/${id}`,
  })
